#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void bubbleS(int list[], int lLength) {
	while(lLength--) 	{
		bool swad = false;
		
		for(int i = 0; i < lLength; i++) {
			if(list[i] > list[i + 1]){
				swap(list[i], list[i + 1]);
				swad = true;
			}
		}	
	
		if(swad == false) break;
	}
}

void readfile(const char *filename, int a[], int length) {
    ifstream file(filename);

    for(int i=0; i < length; i++)
        file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    readfile("m1_sorted.txt",a,LEN);
    unsigned int tstart =  clock();
    bubbleS(a,LEN);
    unsigned int tfinish = clock(); 
    unsigned int twork = tfinish - tstart; 
    cout<<"m1_sorted " << twork << " milliseconds \n";
    
    readfile("m2_reverse.txt",a,LEN);
    tstart =  clock();
    bubbleS(a,LEN);
    tfinish = clock();
    twork = tfinish - tstart; 
    cout<<"m2_reverse " << twork << " milliseconds \n";
    
    readfile("m3_shuffle.txt",a,LEN);
    tstart =  clock(); 
    bubbleS(a,LEN);
    tfinish = clock();
    twork = tfinish - tstart; 
    cout<<"m3_shuffle " << twork << " milliseconds \n";
    
    return 0;
}